package com.example.cavastest;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import java.util.ArrayList;

public class TestCavasView extends View{
    Paint paint;
    private ArrayList<PointF> graphics = new ArrayList<>();
    PointF point;
    public TestCavasView(Context context) {
        super(context);
        paint = new Paint();
        paint.setColor(Color.RED);
        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStrokeCap(Paint.Cap.ROUND);
        paint.setStrokeWidth(8);
    }
    @Override
    public boolean onTouchEvent(MotionEvent event){
        graphics.add(new PointF(event.getX(),event.getY()));
        Log.d("ODBZ","points:" + event.getX() + ":" +event.getY());
        invalidate();
        return true;
    }

    protected void onDraw(Canvas canvas){
        super.onDraw(canvas);
        canvas.drawLine(50,330,300,330,paint);
        for (PointF point : graphics){
            canvas.drawPoint(point.x, point.y, paint);
        }
    }

}
